﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.Core.Algorithm;

namespace Microhard.Core.Printer.POS
{
    public static class PrintExtension
    {
        public static string CreateContent(this object model)
        {
            string result = string.Empty;
            if (model == null)
                return result;
            var objs = AttrAlg.GetCustomerAttribute(model, typeof(POSPrinterAttr));
            if (objs == null)
                return result;
            if (objs.Length == 0)
                return result;
            var ic = objs.First() as POSPrinterAttr;
            if (ic != null)
            {
                IPOSContentTemplate ins = IoC.Resolve(ic.Template) as IPOSContentTemplate;
                result = ins.CreateContent(model);
            }
            return result;
        }
    }
}
